'use strict'

// Note: always annotate the construtors so that we dont get issues when the code is minified
var caseControllers = angular.module('assetPlusApp.casesControllers', []);

caseControllers.controller('casesController',['$scope','$http','caseDetailService', function ($scope, $http, caseDetailService) {
    $scope.controllerId = "casesController";
    $scope.version = "1";
    $scope.cases = caseDetailService.query();

    /*
        $http.get('data/case/cases.json').success(function(data) {
            $scope.cases = data;

        });
    */
    }]);

caseControllers.controller('caseDetailsController',['$scope','$routeParams','$http','caseDetailService', function ($scope, $routeParams, $http, caseDetailService) {
    $scope.controllerId = "caseDetailsController";
    $scope.version = "1";
   // $scope.caseDetail = getCaseDetail();

    $scope.getCaseDetail = caseDetailService.get({serviceId: $routeParams.service_id}, function(caseDetail) {
        $scope.caseDetail = caseDetail;
    });

    $scope.$watch("caseDetail",
        function(newValue, oldValue) {
            console.log("I see a data change! its dirty: oldValue: " + oldValue + ", newValue: " + newValue);
        },
        true);

    $scope.save =
        function() {
            console.log('saving the data');
        }
}]);